package k3_IO.p1_file.demo03;

import java.io.File;

public class CascadeDeleteDir {

    public static void deleteFile(File file){

        //如果当前File是目录，继续向下一个层次遍历
        if(file.isDirectory()){
            File[] files = file.listFiles();
            for (File f : files) {
                deleteFile(f);
            }
        }

        //不管是文件还是目录，都执行删除
        file.delete();

    }


    public static void main(String[] args) {

        File file = new File("E://test5");

        deleteFile(file);

    }

}
